package main

import(
	"fmt"
)

func main(){
	var year, month , day int
	for{
		daysOfMonth := []int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
		fmt.Println("请输入年份：")
		fmt.Scan(&year)
		if !isYearleagl(int(year)){
			fmt.Println("年份输入错误！！")
			continue
		}
		if isLeapYear(int(year)){
			daysOfMonth[1] = 29
		}
		fmt.Println("请输入月份：")
		 fmt.Scan(&month)
		if !isMonthleagl(int(month)){
			fmt.Println("月份输入错误！！")
			continue
		}
		fmt.Println("请输入日期：")
		fmt.Scan(&day)
		if !isDayInMonthLegal(int(day), daysOfMonth[int(month)]){
			fmt.Println("日期输入错误！！")
			continue
		}
		fmt.Printf("输入的日期是：%d 年 %d 月 %d 日 \n", int(year), int(month), int(day))
		fmt.Printf("该月总共的天数为: %d \n", daysOfMonth[int(month) - 1])
	}

}

func isDayInMonthLegal(day, monthTotalDay int) bool{
	return day >= 1  && day <= monthTotalDay
}

func isMonthleagl(month int) bool {
	return month >= 1 && month <= 12
}

func isYearleagl(year int) bool {
	return year >= 0
}

func isLeapYear(year int) bool {
	return year % 4 == 0 && year % 100 != 0 || year % 400 == 0
}